<template>
	<view class="index">
		<div class="cycle">
			<div class="content">
				<image src="https://s1.ax1x.com/2022/11/08/xxld8P.jpg" @click="gogogo1" mode="widthFix"></image>
			</div>
		</div>
		<view class="icon_frame">
			<view v-for="(item,index) in iconList" :key="index" @click="ClickIcon(item)">
				<view class="icon_border">
					<image class="icon_image" :src="item.imageUrl"></image>
					<view class="icon_title">
						{{item.name}}
					</view>
				</view>
			</view>
		</view>
		<div class='div'>
			<image class="icon_image1" src="https://s1.ax1x.com/2022/11/08/xxlwgf.jpg" @click="more" mode="widthFix">
			</image>
		</div>
		<u-popup :show="show" mode="center" :round="20" @close="handleClose" @open="open">
			<view class="gg">
				<u-parse :content="text"></u-parse>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import util from "@/util/index.js"
	export default {

		data() {
			return {
				// tjxhUrl: require("../../static/3x/tjxh.jpg"),
				util: util,
				title: 'Rsc',
				text: '',
				iconList: [{
						name: '我要认养',
						imageUrl: '../../static/3x/egg.jpg',
						path: '/pages/goods-category/goods-category'
					},
					{
						name: '领取鸡蛋',
						imageUrl: '../../static/3x/adoption.jpg',
						path: '/pages/getEggs/getEggs'
					},
					{
						name: '推广码',
						imageUrl: '../../static/3x/promotion.jpg',
						path: '/pages/yard/yard'
					}, {
						name: '认养券充值',
						imageUrl: '../../static/3x/pay.jpg',
						path: '/pages/payment/payment'
					}
				],
				show: false,
			}
		},
		components: {},
		onLoad() {
			this.$http({
				url: '/crmMessage/selAnnMessage'
			}).then(res => {
				const that = this
				res.data.data.forEach(function(item, index) {
					if (item.id == 2) {
						that.text = res.data.data[index].body
						that.open()
					} else {
						return
					}
				})
			})
		},
		methods: {
			more() {
				uni.navigateTo({
					url: '../gogogo/gogogo'
				})
			},
			gogogo1() {
				uni.navigateTo({
					url: '../gogogo1/gogogo1'
				})
			},
			handleClose() {
				this.show = false
			},
			open() {
				//只弹进入第一次
				uni.getStorage({
					key: 'member:login:token:9071d6e81e5c55aa1b4c0d77b5778a45',
					success: () => {
						this.show = false
					},
					fail: () => {
						this.show = true
					}
				})
			},
			ClickIcon(item) {
				if (item.name === "我要认养") {
					uni.switchTab({
						url: item.path
					})
				} else {
					uni.navigateTo({
						url: item.path
					})
				}
			},
		},
	}
</script>
<style lang="scss" scoped>
	@import './index.css';

	.u-demo-block__content {
		@include flex(column);
	}
</style>
